<?php

class User extends AppModel
{
	var $name ='User';
	

	var $validate = array(
		'username' => array( 
					'length' => '/^[a-zA-Z0-9 ]{6,24}$/',
					'unique' => array('rule' => 'UniqueUsername')
					),

		'email' => array(
					'valid' => VALID_EMAIL ,
					'unique' => array('rule' => 'UniqueEmail')
					),
	);


	var $validateNoUnique = array(
		'username' => array( 
					'length' => '/^[a-zA-Z0-9 ]{6,24}$/'
					),

		'email' => array(
					'valid' => VALID_EMAIL 
					),
	);



	function UniqueUsername ($username)
	{
	$return = true ;
	$test = $this->findByUsername($username);
	if ( $test['User']['username'] == $username )
		{ 
		$return = false ;
		}
	return $return;
	}

	function UniqueEmail ($email)
	{
	$return = true ;
	$test = $this->findByEmail($email);
	if ( $test['User']['email'] == $email )
		{
		$return = false ;
		}
	return $return;
	}

	
}




?>
